package com.iamdigger.server.job.cron;

import com.iamdigger.server.common.util.PooledHttpClient;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * oschina.net spider
 * Created by Sam Tsai on 2016/4/26.
 */
@Component
public class OsChinaSpider {
    private static final Logger logger = LoggerFactory.getLogger(OsChinaSpider.class);

    public void doJob() {
        try {
            String randomStr = RandomStringUtils.random(20, true, true);
            logger.info("OSChina Spider Job {} execute..", randomStr);
            String osChinaIdxHtml = PooledHttpClient.doGet("http://www.oschina.net");
            //logger.debug(osChinaIdxHtml);
            logger.info("OSChina Spider Job {} accomplished.", randomStr);
        } catch (Exception e) {
            logger.error("OSChina Spider Job exception", e);
        }
    }
}
